﻿#include "testdb.h"
#include "ui_testdb.h"

#include <constant.h>

#include <DataBase/mysql.h>
#include "qdebug.h"
#include "qthread.h"

TestDB::TestDB(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TestDB)
{
    ui->setupUi(this);
}

TestDB::~TestDB()
{
    delete ui;
}

void TestDB::on_pushButton_clicked()
{
    QString file=Constant::DataBasePath;
    UserInfoBean dataUserInfoBean;
    Qt::HANDLE threadId = QThread::currentThreadId();
    QString threadIdStr = QString::number(reinterpret_cast<quintptr>(threadId));

//    for(int i=0;i<10;i++){

//        if(MySql::getInstance(file,threadIdStr)->MySelect("eee",dataUserInfoBean))
//        {
//            qDebug()<<"true";
//        }else{
//            qDebug()<<"false";
//        }
//    }

    for(int i=0;i<100;i++){
        MySql *mysql=new MySql(file,threadIdStr);
        if(mysql->MySelect("eee",dataUserInfoBean))
        {
            qDebug()<<"true";
        }else{
            qDebug()<<"false";
        }
        delete mysql;
    }

}
